Expose the exceptions thrown by xen.lowlevel.xc so they can be caught.
authorAnthony Liguori <anthony@codemonkey.ws>
Fri, 19 May 2006 16:31:28 +0000 (17:31 +0100)
committerAnthony Liguori <anthony@codemonkey.ws>
Fri, 19 May 2006 16:31:28 +0000 (17:31 +0100)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
tools/python/xen/lowlevel/xc/xc.c

index 59eaa86f67279f9f3cf9a4ef493fa5258fd63b1d..f90dc12d67a98678145129e90f7c7de19b888ddb 100644 (file)
@@ -1172,7 +1172,7 @@ static int
 PyXc_init(XcObject *self, PyObject *args, PyObject *kwds)
 {
     if ((self->xc_handle = xc_interface_open()) == -1) {
-        PyErr_SetFromErrno(PyExc_RuntimeError);
+        PyErr_SetFromErrno(xc_error);
         return -1;
     }
 
@@ -1245,7 +1245,7 @@ PyMODINIT_FUNC initxc(void)
     if (m == NULL)
       return;
 
-    xc_error = PyErr_NewException(PKG ".error", NULL, NULL);
+    xc_error = PyErr_NewException(PKG ".Error", PyExc_RuntimeError, NULL);
     zero = PyInt_FromLong(0);
 
     /* KAF: This ensures that we get debug output in a timely manner. */
@@ -1254,6 +1254,9 @@ PyMODINIT_FUNC initxc(void)
 
     Py_INCREF(&PyXcType);
     PyModule_AddObject(m, CLS, (PyObject *)&PyXcType);
+
+    Py_INCREF(xc_error);
+    PyModule_AddObject(m, "Error", xc_error);
 }